package com.example.webweb.api;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 自定义校验验证接口
 */
public class MyCustomValidator implements ConstraintValidator<MyCustomConstraint, String> {
    @Override
    public void initialize(MyCustomConstraint constraintAnnotation) {
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        // 自定义校验逻辑
        return value != null && value.matches("^[a-zA-Z0-9]*$");  // 例：只允许字母和数字
    }
}
